package liecai_class.day08;

import java.util.concurrent.CountDownLatch;

/**
 * Atomic
 */
public class Demo06 {
    static CountDownLatch cdl = new CountDownLatch(2);
    static int x = 0;
    public static void main(String[] args) throws InterruptedException {
        new Thread(new Runnable() {
            @Override
            public void run() {
                for(int i=0;i<100000;i++){
                    x++;
                }
                cdl.countDown();
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                for(int i=0;i<100000;i++){
                    x++;
                }
                cdl.countDown();
            }
        }).start();

        cdl.await();
        System.out.println(x);
    }
}
